package com.cy.model;

import com.cy.BasicModel;
import com.cy.ext.plugin.tablebind.TableBind;
import com.jfinal.plugin.activerecord.Db;

import static com.cy.utils.SimpleSqlUtils.in;

@TableBind(tableName = "account_map_role", pkName = "id")
public class AccountMapRole extends BasicModel<AccountMapRole> {
    public static final AccountMapRole dao = new AccountMapRole();
    public static final String SELECT_ALL = "`id`,`account_role_id`,`account_id`";
            
    public AccountMapRole setId(Long id){
        return this.set("id",id);
    }

    public Long getId(){
        return this.get("id");
    }

    public AccountMapRole setAccountRoleId(Long accountRoleId){
        return this.set("account_role_id",accountRoleId);
    }

    public Long getAccountRoleId(){
        return this.get("account_role_id");
    }
        
    public AccountMapRole setAccountId(Long accountId){
        return this.set("account_id",accountId);
    }

    public Long getAccountId(){
        return this.get("account_id");
    }

    public void deleteAccountAndRole(Object[] accountIds, Object[] roleIds) {
        Db.update("DELETE FROM account_map_role WHERE "+ in("account_id", accountIds) +" AND "+ in("account_role_id", roleIds));
    }
}
